import { resolveToken } from '../_utils';

const users = {
  admin: {
    id: 1,
    name: '管理员(admin)',
    avatar: '/src/assets/images/avatar.png',
    email: 'm15754857315@xxx.com',
    role: ['admin'],
  },
  editor: {
    id: 2,
    name: '运维(editor)',
    avatar: '/src/assets/images/avatar.png',
    email: 'm15754857315@xxx.com',
    role: ['editor'],
  },
  guest: {
    id: 3,
    name: '访客(guest)',
    avatar: '/src/assets/images/avatar.png',
    role: [],
  },
};
export default [
  {
    url: '/api/auth/findByToken',
    method: 'post',
    response: ({ headers }) => {
      const token = resolveToken(headers?.authorization);
      return {
        code: 0,
        data: {
          ...(users[token] || users.guest),
        },
      };
    },
  },
  {
    url: '/api/auth/list',
    method: 'get',
    response: ({ headers }) => {
      const total = 10;
      const data = [
        { id: 10001, name: 'Test1', nickname: 'T1', role: 'Develop', sex: '1', age: 28, address: 'Shenzhen' },
        { id: 10002, name: 'Test2', nickname: 'T2', role: 'Test', sex: '0', age: 22, address: 'Guangzhou' },
        { id: 10003, name: 'Test3', nickname: 'T3', role: 'PM', sex: '1', age: 32, address: 'Shanghai' },
        { id: 10004, name: 'Test4', nickname: 'T4', role: 'Designer', sex: '0', age: 23, address: 'Shenzhen' },
        { id: 10005, name: 'Test5', nickname: 'T5', role: 'Develop', sex: '0', age: 30, address: 'Shanghai' },
        { id: 10006, name: 'Test6', nickname: 'T6', role: 'Develop', sex: '0', age: 27, address: 'Shanghai' },
        { id: 10007, name: 'Test7', nickname: 'T7', role: 'Develop', sex: '1', age: 29, address: 'Shenzhen' },
        { id: 10008, name: 'Test8', nickname: 'T8', role: 'Develop', sex: '0', age: 32, address: 'Shanghai' },
        { id: 10009, name: 'Test9', nickname: 'T9', role: 'Develop', sex: '1', age: 30, address: 'Shenzhen' },
        { id: 10010, name: 'Test10', nickname: 'T10', role: 'Develop', sex: '0', age: 34, address: 'Shanghai' },
      ];
      return {
        code: 0,
        data: {
          total,
          data,
        },
      };
    },
  },
];
